import 'package:flutter/material.dart';
import 'package:tile/view/painter/painter.dart';

class NavNextPainter extends BoardPointPainter {
  final _paint = Paint();

  final double scale;
  final double opacity;
  final Color color;
  final int nextColor;
  final bool isBest;

  NavNextPainter(
      {this.scale = 1.0,
      this.opacity = 1.0,
      this.color = Colors.red,
      this.nextColor = 1,
      this.isBest = false});

  @override
  paint(
    Canvas canvas, {
    required Rect rect,
    required int chessValue,
    required int flagValue,
    required bool isThumb,
    dynamic flagExtraData,
  }) {
    if (flagExtraData == null) {
      throw Exception("需要传入棋子颜色：extraData->$flagExtraData");
    }

    final center = rect.center;
    final tileSize = rect.width;

    _paint.color = flagExtraData;
    if (opacity != 1.0) {
      _paint.color = _paint.color.withOpacity(opacity);
    }
    canvas.drawCircle(center, tileSize / 2, _paint);
    if (isBest) {
      canvas.drawCircle(center, tileSize * 2 / 5, _paint..color = color);
      canvas.drawCircle(center, tileSize / 3.5,
          _paint..color = nextColor == 1 ? Colors.black : Colors.white);
      canvas.drawCircle(center, tileSize / 7, _paint..color = color);
    } else {
      canvas.drawCircle(center, tileSize / 3, _paint..color = color);
    }
  }
}
